package com.sx.manage.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import com.sx.cache.Cache;

/** **/
@Component
@Configuration
@PropertySource(value = "classpath:redis.properties", encoding = "UTF-8")
public class BeanConfiguration {
	// redis 地址
	@Value("${redis.host}")
	private String redisHost;
	// 端口号
	@Value("${redis.port}")
	private int redisPort;
	// 密码
	@Value("${redis.pwd}")
	private String redisPwd;
	// 超时时间
	@Value("${redis.timeout}")
	private int timeout;
	// 最小连接
	@Value("${redis.pool.maxIdle}")
	private int maxIdle;
	// 最大连接
	@Value("${redis.pool.maxTotal}")
	private int maxTotal;

	/** redus配置 **/
	@Bean(name = "redisCache")
	public Cache createCache() {
		return new Cache(redisHost, redisPort, timeout, redisPwd, maxIdle, maxTotal, false);
	}

//	@Bean
//	ServletWebServerFactory servletWebServerFactory() {
//		return new TomcatServletWebServerFactory();
//	}
}
